<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title> <link rel="stylesheet" href="./css/list.css">
    <style>
        .btn{
            display: flex;
            margin: 20px auto;
            justify-content:space-around;
        }
        .btn button{
            margin-left: 30px;
        }
    </style>
</head>
<body>
    <ul></ul>
    <div class="btn">
        <button class="before">上一页</button>
        <button class="next">下一页</button>
    </div>
   
    <script src="./js/ajax.js"></script>
    <script>
        let next=$('.next')
        let before=$('.before')
        let ul=$('ul')
        let page=1
        function render(page){
            ajax_get({
                url:'http://localhost:8888/goods/list',
                params:{
                    current:page,
                    pagesize:30,
                },
                success(data){
                    let {list}=JSON.parse(data)
                    ul.innerHTML=''
                    console.log(list);
                    list.forEach(item=>{
                        ul.innerHTML+=`
                        <li>
                            <div class="pic">
                                    <img src="${item.img_big_logo}">
                                </div>
                                <p class="title hide">${item.title}</p>
                                <p class="price">${item.price}</p>
                        </li>
                        `
                    })
                }
            })
        }
        render(page)
        next.onclick=()=>{
            page++
            render(page)
        }
        before.onclick=()=>{
            page--
            render(page)
        }
    </script>
    
</body>
</html>